package logic

import (
	"activity/activityRpc/activityRpc"
	"context"

	"activity/api/internal/svc"
	"activity/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListActivityLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewListActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListActivityLogic {
	return &ListActivityLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ListActivityLogic) ListActivity(req *types.ListActivityRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	listActivity, err := l.svcCtx.ActivityRpc.ListActivity(l.ctx, &activityRpc.ListActivityRequest{
		Page: req.Page,
		Size: req.Size,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "活动列表展示成功",
		Code:    200,
		Data:    listActivity,
	}, nil
}
